window.onload = function () {
    var Equation = document.getElementById('Equation');
    var result = document.getElementById('result');
    var btns = document.getElementsByClassName('btn')
    var  over = 0;
    for (let i = 0; i < btns.length; i++) {
        btns[i].addEventListener('click',function (){
            if(btns[i].innerText.trim() == 'C'){
                Equation.value = "";
                result.value = "";
            }else if(btns[i].innerText.trim() == 'CE'){
                Equation.value = "";
            }else if(btns[i].innerText.trim() == '='){
                result.value = eval(Equation.value)
                over = 1;
            }
            else {
                if(over == 1){
                    Equation.value = "";
                    over = 0;
                }
                Equation.value += btns[i].innerText.trim();
                console.log(btns[i].innerText)
            }
        })
    }
}